package com.balabala.gym_user.controller.app;

import com.balabala.gym_user.pojo.entity.VipCard;
import com.balabala.gym_user.service.VipCardService;
import com.balabala.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Author:zl
 * Date:2023/5/8 20:18
 */
@RestController
@RequestMapping("/app/vipCard")
@Api(tags = "小程序会员卡类型接口")
@CrossOrigin
@Slf4j
public class VipDetailsController {
    @Autowired
private VipCardService vipCardService;

    @ApiOperation("查询所有会员卡")
    @GetMapping("/findAll")
    public Result findAll() {
        List<VipCard> list = vipCardService.list();
        return Result.ok(list);
    }
    @ApiOperation("根据vip卡类型查找(0: 次卡 1 期卡 2 储值卡)")
    @GetMapping("/findCardByCardType/{cardType}")
    public Result findCardByCardType(@PathVariable("cardType") Integer cardType) {
        List<VipCard> byCardType = vipCardService.findByCardType(cardType);
        return Result.ok(byCardType);
    }
    @ApiOperation("根据id查询会员卡信息)")
    @GetMapping("/findCardById/{id}")
    public Result findCardById(@PathVariable("id") Long id) {
        VipCard byId = vipCardService.getById(id);
        return Result.ok(byId);
    }
}
